<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>    
<%@ taglib prefix="display" uri="http://displaytag.sf.net" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %> 
 
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>  
<!--area_lista_serv_autista.jsp--> 
<script type="text/javascript">
var listaAutisti =<c:out value="${listaAutisti}" escapeXml="false" 	/>;

    $(document).ready(function () {
        $('#listServizi').jtable({
        	defaultDateFormat: 'dd/mm/yy',
        	paging: true,
        	pagesize: 10,
        	pageList: 'minimal',
        	sorting: 'true',
            title: 'Lista Servizi ricevuti ed inviati da <c:out value="${coll.nome}" />',
            toolbar: {
            	 hoverAnimation: true, //Enable/disable small animation on mouse hover to a toolbar item.
            	 hoverAnimationDuration: 60, //Duration of the hover animation.
           	     hoverAnimationEasing: undefined, //Easing of the hover animation. Uses jQuery's default animation ('swing') if set to undefined.
            	    
                items: [{
                    icon: '/images/excel.png',
                    text: 'Export to Excel',
                    click: function () {
                        //perform your custom job...
                    }
                },{
                    icon: '/images/pdf.png',
                    text: 'Export to Pdf',
                    click: function () {
                        //perform your custom job...
                    }
                }]
            },
            actions: {
                listAction: '<%=request.getContextPath()%>/areaPrivata/ajax/loadServiziCollaboratore.html?id=<c:out value="${coll.idAutista}" />',
                updateAction: '<%=request.getContextPath()%>/areaPrivata/ajax/editServizio.html',
                deleteAction: '<%=request.getContextPath()%>/areaPrivata/ajax/deleteServizio.html'
            },
            fields: {
                idServ: {
                    key: true,
                    list: false,
                    create: false,
                    edit: false
                },
                idServUserJson: {
                    title: 'Id',
                    width: '4%',
                    create: false,
                    edit: false,
                    display: function (data) {
                    	if (data.record) {
                    		return data.record.idServUser;
                    	}
                    }
                },
                idServUser: {
                    create: false,
                    type: 'hidden',
                    defaultValue: function (data) {return data.record.idServUser; }
                },
//                 idUserInse: {
//                     type: 'hidden'
//                 },
                tipoServizio: {
                	list: false,
                    title: 'Tipo Corsa',
                    width: '8%',
                    options: { '1': 'Transfer', '2': 'Disposizione' }
                },   
                dataInseJson: {
                    create: false,
                    edit: false,
                    type: 'hidden'
                    
                },
             
                oraJson: {
                    title: 'Ora',
                    width: '3%',
                    sorting: false,
                	inputClass: 'validate[required,custom[orario]]'
                },
                dataJson: {
                    title: 'Data',
                    width: '7%',
                    type: 'date',
                    inputClass: 'validate[required]',
                    listClass: 'grassetto'
                 //   inputClass: 'validate[funcCall[checkData],required]'
                },
                'idCliente': {
                    type: 'hidden',
                 	defaultValue: function (data) {return data.record.cliente.idCliente; },
                	create: false
                },
                'cliente.descNome': {
                	title: 'Cliente',
                    width: '10%',
                    sorting: true,
	                 display: function (data) {
	                	 var str = data.record.cliente.descNome +'<br/>'+ data.record.cliente.telefono  +'<br/>'+ data.record.cliente.email;
	                     return str;
	                 },
	                input: function (data) {
	                    if (data.record) {
	                        return '<input type="text" name="cliente.descNome" style="width:200px" value="' + data.record.cliente.descNome + '" />';
	                    } else {
	                        return '<input type="text" name="cliente.descNome" style="width:200px" />';
	                    }
	                }
             	},
                'cliente.telefono': {
                	title: 'Tel.',
		            list: false,
		            
	                 display: function (data) {
	                     return data.record.cliente.telefono;
	                 },
	                input: function (data) {
	                		if (data.record) {
	                        	return '<input type="text" name="cliente.telefono" style="width:200px" value="' + data.record.cliente.telefono + '" />';
	                        } else {
	                        	return '<input type="text" name="cliente.telefono" style="width:200px" value="" />';
	                        }
	                }
             	},  
                'cliente.email': {
                	title: 'Email Cliente',
                    list: false,
	                 display: function (data) {
	                     return data.record.cliente.email;
	                 },
	                input: function (data) {
	                    if (data.record) {
	                        return '<input type="text" name="cliente.email" style="width:200px" value="' + data.record.cliente.email + '" />';
	                    } else {
	                        return '<input type="text" name="cliente.email" style="width:200px" />';
	                    }
	                }
             	},              	
                pax : {
                    title: 'Pax',
                    width: '3%',
                    options: ['1','2','3','5','6','7','8','9','10','15','25'],
                    sorting: false
                    
                },
                volo: {
                    title: 'Volo / Nave',
                    width: '5%'
                },
                
                pickUp: {
                    title: 'Pick up',
                    width: '17%'
                },
                dropOff: {
                    title: 'Drop off',
                    width: '17%'
                },
                
                prezzo: {
                    title: '&euro;',
                    width: '4%',
                    listClass: 'grassetto',
                    defaultValue: '0',
                    display:	function (data) {
	                    if (data.record) {
	                        return '&euro; ' + data.record.prezzo;
	                    } 
                    }
                	
                },
                dare: {
                    title: 'Dare',
                    width: '3%',
                    defaultValue: '0'
                },
                avere: {
                    title: 'Avere',
                    width: '3%',
                    defaultValue: '0'
                },    
                inout: {
                    title: 'Ricevuto/Inviato',
                    edit: false,
                    create: false,
                    width: '4%',
                    listClass: 'grassetto',
                    defaultValue: '0',
                    display:	function (data) {
	                    if (data.record) {
	                    	var str;
	                    	if (data.record.idAutista == <c:out value="${coll.idAutista}" /> ) {
		                    	 str = '<div class="centrato" ><img class="centrato" src="<%=request.getContextPath()%>/i/corsa_out.png" alt="Servizio Inviato" width="29" height="23" /></div>';
	                    	} else if (data.record.sorgente.idSorgente == <c:out value="${coll.idAutista}" /> ) {
	                    		 str = '<div class="centrato" ><img class="centrato" src="<%=request.getContextPath()%>/i/corsa_in.png" alt="Servizio Ricevuto" width="29" height="23" /></div>';
	                    	}
	                    	return str; 
	                    } 
                    }
                	
                },
                idSorgente : {
                    title: 'Ricevuto da:',
                    options: listaAutisti,
                    list: false
                },
                idAutista : {
                    title: 'Eseguito da',
                    list: false,
                    options: listaAutisti//function (data) { return data.record.nomeAutista; }
                },
                descTipoServizio: {
                    title: 'Tipo Corsa',
                    width: '8%',
                    edit: false,
                    create: false,
				    sorting: false
                },
                       
//                  TestColumn: {
//                      title: 'Test',
//                      display: function (data) {
//                          return data.record.cliente.descNome;
//                      }
//                  }
                    
            },
            //Initialize validation logic when a form is created
            formCreated: function (event, data) {
                data.form.validationEngine();
            },
            //Validate form when it is being submitted
            formSubmitting: function (event, data) {
                return data.form.validationEngine('validate');
            },
            //Dispose validation logic when form is closed
            formClosed: function (event, data) {
                data.form.validationEngine('hide');
                //data.form.validationEngine('detach');
            }
        });
        
        $('#listServizi').jtable('load');

    });
    
    
    function checkData(field, rules, i, options){
    		    var pattern = /^(0?[1-9]|[12][0-9]|3[01])[\/\-\.](0?[1-9]|1[012])[\/\-\.]([0-9]{4})$/; 
    		    var str = field.val();
    		    if (!str.match(pattern)) {
    	    	     return options.allrules.validate2fields.alertText;

    		    }
    		    
    	     // this allows the use of i18 for the error msgs
   }

    
    
    

    
</script>
			
			
	<!-- INIZIO CONTENUTO -->
				
<div id="listServizi" class="listaJtable"></div>
	<!-- FINE CONTENUTO -->












</div>
		</div>			
		
		
		
		
		
		
		
		
		
		
		
		
		<%-- 








<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>    
<%@ taglib prefix="display" uri="http://displaytag.sf.net" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>  

    <!-- content -->		
   	<div id="content" align="center">
   		   					Lista servizi assegnati all'autista <strong><c:out value="${dettaglio.appoNomeAutista}" /></strong> 
   							<form action="listaServiziAutista.html">
   							<table>
								<tr>
									<td width="25%" >Visualizza servizi a partire dal:
									<br />
									<input type="text"  id="dataIniz3" name="dataIniz3" size="10" maxlength="10" value="${dataIniz}"/>
										<img
											src="<%=request.getContextPath()%>/images/Calendario.gif"
											id="f_imgCal_a"
											style="cursor: pointer; border: 0px; vertical-align: middle; margin-bottom: .40em;"
											title="Calendario" alt="Calendario" title="Calendario" /> <script
											type="text/javascript">
												            Calendar.setup({
												                inputField  : "dataIniz3", // id of the input field
												                ifFormat    : "%d/%m/%Y",        // format of the input field
												                button      : "f_imgCal_a",      // trigger for the calendar (button ID)
												                align       : "Tl",              // alignment (defaults to "Bl")
												                singleClick : true
												            });
												        </script>
									</td>
								
									<td width="25%" >al:
									<br />
									<input type="text"  id="dataFine3" name="dataFine3" size="10" maxlength="10" value="${dataFine}"/>
										<img
											src="<%=request.getContextPath()%>/images/Calendario.gif"
											id="f_imgCal_b"
											style="cursor: pointer; border: 0px; vertical-align: middle; margin-bottom: .40em;"
											title="Calendario" alt="Calendario" title="Calendario" /> <script
											type="text/javascript">
												            Calendar.setup({
												                inputField  : "dataFine3", // id of the input field
												                ifFormat    : "%d/%m/%Y",        // format of the input field
												                button      : "f_imgCal_b",      // trigger for the calendar (button ID)
												                align       : "Tl",              // alignment (defaults to "Bl")
												                singleClick : true
												            });
												        </script>
												        
									</td>
								</tr>
								<tr>
								  <td colspan="2"><input type="submit" value="Filtra" /></td>
								</tr>
								
							</table>
							
							</form>
							
							
						
   		<br />
   		<div align="center"><c:if test="${dettaglio.tipoAccesso == 1}"> <a class="bottone" href="./inserimento.html">Inserisci Servizio</a></c:if></div>
   		<br />
   		<jsp:include page="tabellaServizi.jsp"></jsp:include>
		<br />
   			<c:if test="${back == null}">
   				<c:set var="back" value="listaServizi.html" /> 
   			</c:if>
		<a class="bottone" href="<c:out value="${back}" />" > Indietro </a> &nbsp;

				<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
				<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
				<br /><br /><br /><br /><br /><br />
			</div>
			<div id="aside">
				<h3>
					Suggerimenti
				</h3>
				<p>
					Questa pagina mostra i servizi che hai inserito e assegnato ad un determinato autista/utente 
				</p>
				
				<c:if test="${dettaglio.tipoAccesso == 'A'}">
				<p>
					<strong>"Invita Utente"</strong> Utilizza questa funzione per permettere ad altri utenti iscritti di interagire con questa area
				</p>
				</c:if>
			</div>
			 --%>